package com.common.upload;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.fileupload.ProgressListener;
import org.apache.log4j.Logger;

public class FileUploadListener implements ProgressListener {
	Logger log = Logger.getLogger(this.getClass());
	private HttpServletRequest request = null;

	public FileUploadListener(HttpServletRequest request) {
		this.request = request;
		request.getSession().setAttribute("uploadInfo", new UploadInfo(1, request.getContentLength(), 0,0,"start"));
		//log.info("====start====request.getContentLength()====="+request.getContentLength());
	}

	/**
	 * 更新状态
	 */
	public void update(long pBytesRead, long pContentLength, int pItems) {
		request.getSession().setAttribute("uploadInfo", new UploadInfo(pItems, pContentLength, pBytesRead,1,"progress"));
	}
}
